package miage.unice.util;

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JTree;
import javax.swing.filechooser.FileSystemView;
import javax.swing.tree.DefaultTreeCellRenderer;


public class FileRenderer extends DefaultTreeCellRenderer{
	
	public FileRenderer(){
		super();	
	}	
	
	public Component getTreeCellRendererComponent(JTree tree,Object value,boolean selected,boolean expanded,boolean leaf,int row,boolean hasFocus){
		JLabel label = (JLabel)super.getTreeCellRendererComponent(tree,value,selected,expanded,leaf,row,hasFocus);
		Noeud noeud = (Noeud)value;
		FileSystemView sys = FileSystemView.getFileSystemView();
		label.setText(sys.getSystemDisplayName(noeud.getFile()));
		label.setIcon(sys.getSystemIcon(noeud.getFile()));
		return label;
	}	
}